package com.tbit.main.controller;

import com.tbit.main.common.JsonResult;
import com.tbit.main.pojo.GeoreGion;
import com.tbit.main.pojo.MachineDaySta;
import com.tbit.main.pojo.OperationData;
import com.tbit.main.pojo.OperationGeoMachine;
import com.tbit.main.service.GeoreGionService;
import com.tbit.main.service.MachineDayStaService;
import com.tbit.main.util.Assert;
import com.tbit.main.util.DateTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.*;

/**
 * 分区车辆统计折线图
 *
 * @author LMY
 * @create 2021-07-06 10:36
 */
@RestController
@RequestMapping("/operationGeo")
public class OperationReportGeoController {

    DecimalFormat df = new DecimalFormat("0.00");
    @Autowired
    private MachineDayStaService machineDayStaService;
    @Autowired
    private GeoreGionService georeGionService;

    /**
     * 分区车辆折线图
     */
    @RequestMapping("/machine")
    public JsonResult machine(OperationGeoMachine operationGeoMachine) throws ParseException {
        Assert.hasLength(operationGeoMachine.getStartTime(), "System.startTime.notNull");
        Assert.hasLength(operationGeoMachine.getEndTime(), "System.endTime.notNull");
        Assert.notNull(operationGeoMachine.getRegionId(), "AccountUser.agentId.notNull");

        /**获取分区名称*/
        List<GeoreGion> geoRegions = georeGionService.getAll();
        Map<Integer, String> geoRegionMap = new HashMap<>();
        for (GeoreGion georeGion : geoRegions) {
            geoRegionMap.put(georeGion.getRegionId(), georeGion.getRegionName());
        }

        if (operationGeoMachine.getType() == null) {
            operationGeoMachine.setType(1);
        }
        List<MachineDaySta> machineDayStaList = null;
        /**日统计*/
        if (operationGeoMachine.getType().equals(1)) {
            if (DateTimeUtil.getYYMMDD(operationGeoMachine.getEndTime()).equals(DateTimeUtil.getNowTimeYMD())) {
                operationGeoMachine.setEndTime(DateTimeUtil.getEndDateTimeBefore(-1));
            }
            machineDayStaList = machineDayStaService.getByAccountIdDateDay(null, operationGeoMachine.getRegionId(), operationGeoMachine.getStartTime(), operationGeoMachine.getEndTime());
        }
        /**周统计*/
        else if (operationGeoMachine.getType().equals(2)) {
            machineDayStaList = machineDayStaService.getByAccountIdDateWeek(null, operationGeoMachine.getRegionId(), operationGeoMachine.getStartTime(), operationGeoMachine.getEndTime());
        }
        /** 月统计*/
        else if (operationGeoMachine.getType().equals(3)) {
            machineDayStaList = machineDayStaService.getByAccountIdDateMonth(null, operationGeoMachine.getRegionId(), operationGeoMachine.getStartTime(), operationGeoMachine.getEndTime());
        }


        /**拼接数据*/
        Map<Integer, List<OperationData>> mapNew = new HashMap<>();
        for (MachineDaySta machineDaySta : machineDayStaList) {
            if (mapNew.get(machineDaySta.getRegionId()) == null) {
                List<OperationData> operationDataList = new LinkedList<>();

                Map<Integer, OperationData<Float>> operationDataMap = new HashMap<>();
                Map<Integer, List<Float>> floatList = new HashMap<>();
                Map<Integer, Float> floatMap = new HashMap<>();


                for (int i = 0; i <= 10; i++) {
                    OperationData<Float> operationData = new OperationData();

                    operationData.setName(geoRegionMap.get(machineDaySta.getRegionId()));
                    List<Float> datas = new LinkedList<>();
                    Float data = null;

                    operationDataMap.put(i, operationData);
                    floatList.put(i, datas);
                    floatMap.put(i, data);
                }

                if (geoRegionMap.get(machineDaySta.getRegionId()) == null) {
                    for (Integer key : floatMap.keySet()) {
                        floatMap.put(key, (float) 0.00);
                    }
                } else {
                    if (operationGeoMachine.getType().equals(1)) {
                        for (Integer key : floatMap.keySet()) {
                            switch (key) {
                                case 0:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getCountMachine())));
                                    break;
                                case 1:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getIntoMachine())));
                                    break;
                                case 2:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getOutMachine())));
                                    break;
                                case 3:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackParkpoint())));
                                    break;
                                case 4:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackArea())));
                                    break;
                                case 5:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackSuper())));
                                    break;
                                case 6:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackBattery())));
                                    break;
                                case 7:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackState())));
                                    break;
                                case 8:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackFault())));
                                    break;
                                case 9:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackBorrow())));
                                    break;
                                case 10:
                                    floatMap.put(key, Float.parseFloat(df.format((float) machineDaySta.getLackPowerMachineCount())));
                                    break;
                            }
                        }
                    } else if (operationGeoMachine.getType().equals(2)) {
                        for (Integer key : floatMap.keySet()) {
                            switch (key) {
                                case 0:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getCountMachine() / 7))));
                                    break;
                                case 1:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getIntoMachine() / 7))));
                                    break;
                                case 2:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getOutMachine() / 7))));
                                    break;
                                case 3:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackParkpoint() / 7))));
                                    break;
                                case 4:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackArea() / 7))));
                                    break;
                                case 5:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackSuper() / 7))));
                                    break;
                                case 6:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackBattery() / 7))));
                                    break;
                                case 7:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackState() / 7))));
                                    break;
                                case 8:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackFault() / 7))));
                                    break;
                                case 9:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackBorrow() / 7))));
                                    break;
                                case 10:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackPowerMachineCount() / 7))));
                                    break;
                            }
                        }
                    } else if (operationGeoMachine.getType().equals(3)) {
                        for (Integer key : floatMap.keySet()) {
                            switch (key) {
                                case 0:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getCountMachine() / 31))));
                                    break;
                                case 1:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getIntoMachine() / 31))));
                                    break;
                                case 2:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getOutMachine() / 31))));
                                    break;
                                case 3:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackParkpoint() / 31))));
                                    break;
                                case 4:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackArea() / 31))));
                                    break;
                                case 5:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackSuper() / 31))));
                                    break;
                                case 6:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackBattery() / 31))));
                                    break;
                                case 7:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackState() / 31))));
                                    break;
                                case 8:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackFault() / 31))));
                                    break;
                                case 9:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackBorrow() / 31))));
                                    break;
                                case 10:
                                    floatMap.put(key, Float.parseFloat(df.format((float) (machineDaySta.getLackPowerMachineCount() / 31))));
                                    break;
                            }
                        }
                    }
                }

                for (Integer key : floatList.keySet()) {
                    floatList.get(key).add(floatMap.get(key));
                }

                for (Integer key : operationDataMap.keySet()) {
                    operationDataMap.get(key).setData(floatList.get(key));
                }

                //时间
                List<String> times = new LinkedList<>();
                List<String> weeks = new LinkedList<>();
                String time = null;
                String week = null;

                if (operationGeoMachine.getType().equals(1)) {
                    time = machineDaySta.getMachineDate();
                } else if (operationGeoMachine.getType().equals(2)) {
                    week = machineDaySta.getDateWeek();
                    time = machineDaySta.getMachineDate();
                    weeks.add(week);
                } else if (operationGeoMachine.getType().equals(3)) {
                    time = machineDaySta.getDateMonth();
                }
                times.add(time);

                for (Integer keyInteger : operationDataMap.keySet()) {
                    operationDataMap.get(keyInteger).setTime(times);
                    operationDataMap.get(keyInteger).setWeek(weeks);
                    operationDataList.add(operationDataMap.get(keyInteger));
                }
                mapNew.put(machineDaySta.getRegionId(), operationDataList);
            } else {
                if (geoRegionMap.get(machineDaySta.getRegionId()) == null) {
                    for (int i = 0; i <= 10; i++) {
                        mapNew.get(machineDaySta.getRegionId()).get(i).getData().add((float) 0.00);
                    }
                } else {
                    if (operationGeoMachine.getType().equals(1)) {
                        for (int i = 0; i <= 10; i++) {
                            switch (i) {
                                case 0:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getCountMachine());
                                    break;
                                case 1:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getIntoMachine());
                                    break;
                                case 2:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getOutMachine());
                                    break;
                                case 3:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackParkpoint());
                                    break;
                                case 4:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackArea());
                                    break;
                                case 5:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackSuper());
                                    break;
                                case 6:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackBattery());
                                    break;
                                case 7:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackState());
                                    break;
                                case 8:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackFault());
                                    break;
                                case 9:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackBorrow());
                                    break;
                                case 10:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(machineDaySta.getLackPowerMachineCount());
                                    break;
                            }
                        }
                    } else if (operationGeoMachine.getType().equals(2)) {
                        for (int i = 0; i <= 10; i++) {
                            switch (i) {
                                case 0:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getCountMachine() / 7))));
                                    break;
                                case 1:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getIntoMachine() / 7))));
                                    break;
                                case 2:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getOutMachine() / 7))));
                                    break;
                                case 3:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackParkpoint() / 7))));
                                    break;
                                case 4:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackArea() / 7))));
                                    break;
                                case 5:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackSuper() / 7))));
                                    break;
                                case 6:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackBattery() / 7))));
                                    break;
                                case 7:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackState() / 7))));
                                    break;
                                case 8:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackFault() / 7))));
                                    break;
                                case 9:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackBorrow() / 7))));
                                    break;
                                case 10:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackPowerMachineCount() / 7))));
                                    break;
                            }
                        }
                    } else if (operationGeoMachine.getType().equals(3)) {
                        for (int i = 0; i <= 10; i++) {
                            switch (i) {
                                case 0:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getCountMachine() / 31))));
                                    break;
                                case 1:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getIntoMachine() / 31))));
                                    break;
                                case 2:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getOutMachine() / 31))));
                                    break;
                                case 3:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackParkpoint() / 31))));
                                    break;
                                case 4:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackArea() / 31))));
                                    break;
                                case 5:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackSuper() / 31))));
                                    break;
                                case 6:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackBattery() / 31))));
                                    break;
                                case 7:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackState() / 31))));
                                    break;
                                case 8:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackFault() / 31))));
                                    break;
                                case 9:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackBorrow() / 31))));
                                    break;
                                case 10:
                                    mapNew.get(machineDaySta.getRegionId()).get(i).getData().add(Float.parseFloat(df.format((float) (machineDaySta.getLackPowerMachineCount() / 31))));
                                    break;
                            }
                        }
                    }
                }

                if (operationGeoMachine.getType().equals(1)) {
                    mapNew.get(machineDaySta.getRegionId()).get(0).getTime().add(machineDaySta.getMachineDate());
                } else if (operationGeoMachine.getType().equals(2)) {
                    mapNew.get(machineDaySta.getRegionId()).get(0).getTime().add(machineDaySta.getMachineDate());
                    mapNew.get(machineDaySta.getRegionId()).get(0).getWeek().add(machineDaySta.getDateWeek());
                } else if (operationGeoMachine.getType().equals(3)) {
                    mapNew.get(machineDaySta.getRegionId()).get(0).getTime().add(machineDaySta.getDateMonth());
                }
            }
        }

        if (mapNew.size() != operationGeoMachine.getRegionId().size()) {
            for (Integer i : operationGeoMachine.getRegionId()) {
                if (mapNew.get(i) == null) {
                    GeoreGion georeGion = georeGionService.getByRegionId(i);
                    List<OperationData> operationDataList = new LinkedList<>();

                    Map<Integer, OperationData<Float>> map = new HashMap<>();
                    Map<Integer, List<Float>> listMap = new HashMap<>();
                    Map<Integer, Float> floatMap = new HashMap<>();
                    for (int j = 0; j <= 10; j++) {
                        OperationData<Float> operationDataCount = new OperationData();
                        operationDataCount.setName(georeGion.getRegionName());
                        map.put(j, operationDataCount);

                        List<Float> dataCounts = new LinkedList<>();
                        listMap.put(j, dataCounts);

                        Float dataCount = (float) 0.00;
                        floatMap.put(j, dataCount);
                    }

                    for (Integer key : listMap.keySet()) {
                        listMap.get(key).add(floatMap.get(key));
                    }

                    for (Integer key : map.keySet()) {
                        map.get(key).setData(listMap.get(key));
                    }

                    //时间
                    List<String> times = new LinkedList<>();
                    List<String> weeks = new LinkedList<>();
                    String time = null;
                    String week = null;

                    if (operationGeoMachine.getType().equals(1)) {
                        time = DateTimeUtil.getYYMMDD(operationGeoMachine.getStartTime());
                    } else if (operationGeoMachine.getType().equals(2)) {
                        time = DateTimeUtil.getYYMMDD(operationGeoMachine.getStartTime());
                        week = DateTimeUtil.getStringWeek(operationGeoMachine.getStartTime());
                        weeks.add(week);
                    } else if (operationGeoMachine.getType().equals(3)) {
                        time = operationGeoMachine.getStartTime().substring(0, 7);
                    }
                    times.add(time);

                    for (Integer key : map.keySet()) {
                        map.get(key).setTime(times);
                        map.get(key).setWeek(weeks);
                    }

                    for (int k = 0; k <= 10; k++) {
                        operationDataList.add(map.get(k));
                    }
                    mapNew.put(georeGion.getRegionId(), operationDataList);
                }
            }
        }

        List<List<OperationData>> operationDataList = new LinkedList<>();
        for (Integer key : mapNew.keySet()) {
            operationDataList.add(mapNew.get(key));
        }
        for (List<OperationData> operationData : operationDataList) {
            /**补充数据*/
            if (operationGeoMachine.getType().equals(1)) {
                List<String> list = DateTimeUtil.findDates(operationGeoMachine.getStartTime(), operationGeoMachine.getEndTime());

                Map<Integer, Map<String, Float>> map = new HashMap<>();
                for (int i = 0; i <= 10; i++) {
                    Map<String, Float> listDate = new TreeMap<>(new Comparator<String>() {
                        public int compare(String obj1, String obj2) {
                            return obj1.compareTo(obj2);
                        }
                    });
                    map.put(i, listDate);
                }

                for (String i : list) {
                    for (Integer key : map.keySet()) {
                        map.get(key).put(i, (float) 0.00);
                    }
                }

                List<String> time = new LinkedList<>();
                Map<Integer, List<Float>> mapFloat = new HashMap<>();
                for (int i = 0; i <= 10; i++) {
                    List<Float> dateCount = new LinkedList<>();
                    mapFloat.put(i, dateCount);
                }

                if (operationData.size() > 0) {
                    time = operationData.get(0).getTime();
                    for (int k = 0; k <= 10; k++) {
                        mapFloat.put(k, operationData.get(k).getData());
                    }
                }

                Map<Integer, Map<String, Float>> mapMap = new HashMap<>();
                if (time.size() != map.get(0).size()) {
                    for (int q = 0; q <= 10; q++) {
                        Map<String, Float> mapCount = new TreeMap<>(new Comparator<String>() {
                            public int compare(String obj1, String obj2) {
                                return obj1.compareTo(obj2);
                            }
                        });
                        mapMap.put(q, mapCount);
                    }

                    for (int i = 0; i < mapFloat.get(0).size(); i++) {
                        for (Integer key : mapMap.keySet()) {
                            mapMap.get(key).put(time.get(i), mapFloat.get(key).get(i));
                        }
                    }

                    for (Integer key : map.keySet()) {
                        map.get(key).putAll(mapMap.get(key));
                    }

                    List<String> timeMap = new LinkedList<>();
                    Map<Integer, List<Float>> listMap = new HashMap<>();
                    for (int w = 0; w <= 10; w++) {
                        List<Float> dateMap = new LinkedList<>();
                        listMap.put(w, dateMap);
                    }

                    for (String key : map.get(0).keySet()) {
                        timeMap.add(key);
                        for (Integer kk : listMap.keySet()) {
                            listMap.get(kk).add(map.get(kk).get(key));
                        }
                    }

                    if (operationData.size() == 0) {
                        List<OperationData> operationDataLists = new LinkedList<>();
                        for (int k = 0; k <= 10; k++) {
                            OperationData<Float> operationData1 = new OperationData<>();
                            operationData1.setName(operationData.get(k).getName());
                            operationData1.setData(listMap.get(k));
                            operationData1.setTime(timeMap);
                            operationDataLists.add(operationData1);
                        }
                    } else {
                        for (int k = 0; k <= 10; k++) {
                            operationData.get(k).setTime(timeMap);
                            operationData.get(k).setData(listMap.get(k));
                        }
                    }
                }
            } else if (operationGeoMachine.getType().equals(2)) {
                Map<String, String> listTime = DateTimeUtil.getDayOfWeekWithinDateInterval(operationGeoMachine.getStartTime(), operationGeoMachine.getEndTime(), 1);
                List<String> time = new LinkedList<>();
                List<String> week = new LinkedList<>();
                Map<Integer, List<Float>> mapListMap = new HashMap<>();
                for (int i = 0; i <= 10; i++) {
                    List<Float> money = new LinkedList<>();
                    mapListMap.put(i, money);
                }

                if (operationData.size() > 0) {
                    time = operationData.get(0).getTime();
                    week = operationData.get(0).getWeek();
                    for (Integer key : mapListMap.keySet()) {
                        mapListMap.put(key, operationData.get(key).getData());
                    }
                }

                if (time.size() != listTime.size()) {
                    Map<Integer, Map<String, Float>> mapMap = new HashMap<>();
                    for (int i = 0; i <= 10; i++) {
                        Map<String, Float> listMoney = new TreeMap<>(new Comparator<String>() {
                            public int compare(String obj1, String obj2) {
                                return obj1.compareTo(obj2);
                            }
                        });
                        mapMap.put(i, listMoney);
                    }

                    for (String key : listTime.keySet()) {
                        for (Integer keyMap : mapMap.keySet()) {
                            mapMap.get(keyMap).put(key, (float) 0.00);
                        }
                    }

                    Map<String, String> mapWeekTime = new TreeMap<>(new Comparator<String>() {
                        public int compare(String obj1, String obj2) {
                            return obj1.compareTo(obj2);
                        }
                    });

                    for (int i = 0; i < week.size(); i++) {
                        mapWeekTime.put(week.get(i), time.get(i));
                    }

                    Map<Integer, Map<String, Float>> mapMapWeek = new HashMap<>();
                    for (int k = 0; k <= 10; k++) {
                        Map<String, Float> mapWeekMoney = new TreeMap<>(new Comparator<String>() {
                            public int compare(String obj1, String obj2) {
                                return obj1.compareTo(obj2);
                            }
                        });
                        mapMapWeek.put(k, mapWeekMoney);
                    }

                    for (int i = 0; i < week.size(); i++) {
                        for (Integer keyWeek : mapMapWeek.keySet()) {
                            mapMapWeek.get(keyWeek).put(week.get(i), mapListMap.get(keyWeek).get(i));
                        }
                    }

                    for (Integer key : mapMap.keySet()) {
                        mapMap.get(key).putAll(mapMapWeek.get(key));
                    }

                    List<String> timeMap = new LinkedList<>();
                    Map<Integer, List<Float>> map = new HashMap<>();
                    for (int i = 0; i <= 10; i++) {
                        List<Float> moneyMap = new LinkedList<>();
                        map.put(i, moneyMap);
                    }

                    for (String key : listTime.keySet()) {
                        timeMap.add(listTime.get(key));
                        for (Integer keyList : map.keySet()) {
                            map.get(keyList).add(mapMap.get(keyList).get(key));
                        }
                    }

                    if (operationData.size() == 0) {
                        List<OperationData> operationDataLists = new LinkedList<>();
                        for (int i = 0; i <= 10; i++) {
                            OperationData<Float> operationData1 = new OperationData<>();
                            operationData1.setName(operationData.get(i).getName());
                            operationData1.setData(map.get(i));
                            operationData1.setTime(timeMap);
                            operationDataLists.add(operationData1);
                        }
                    } else {
                        for (int i = 0; i <= 10; i++) {
                            operationData.get(i).setTime(timeMap);
                            operationData.get(i).setData(map.get(i));
                        }
                    }
                }
            } else if (operationGeoMachine.getType().equals(3)) {
                List<String> monthDay = DateTimeUtil.getMonthDay(operationGeoMachine.getStartTime(), operationGeoMachine.getEndTime());
                Map<Integer, Map<String, Float>> map = new HashMap<>();
                for (int i = 0; i <= 10; i++) {
                    Map<String, Float> moneyData = new TreeMap<>();
                    map.put(i, moneyData);
                }

                for (String k : monthDay) {
                    for (Integer key : map.keySet()) {
                        map.get(key).put(k, (float) 0.00);
                    }
                }

                List<String> time = new LinkedList<>();
                Map<Integer, List<Float>> listMap = new HashMap<>();
                for (int i = 0; i <= 10; i++) {
                    List<Float> money = new LinkedList<>();
                    listMap.put(i, money);
                }

                if (operationData.size() > 0) {
                    time = operationData.get(0).getTime();
                    for (Integer key : listMap.keySet()) {
                        listMap.put(key, operationData.get(key).getData());
                    }
                }

                if (time.size() != monthDay.size()) {
                    Map<Integer, Map<String, Float>> mapMap = new HashMap<>();
                    for (int i = 0; i <= 10; i++) {
                        Map<String, Float> mapMoney = new TreeMap<>(new Comparator<String>() {
                            public int compare(String obj1, String obj2) {
                                return obj1.compareTo(obj2);
                            }
                        });
                        mapMap.put(i, mapMoney);
                    }

                    for (int i = 0; i < listMap.get(0).size(); i++) {
                        for (Integer k : mapMap.keySet()) {
                            mapMap.get(k).put(time.get(i), listMap.get(k).get(i));
                        }
                    }

                    for (Integer keyMap : map.keySet()) {
                        map.get(keyMap).putAll(mapMap.get(keyMap));
                    }

                    List<String> timeMap = new LinkedList<>();
                    Map<Integer, List<Float>> integerListMap = new HashMap<>();
                    for (int i = 0; i <= 10; i++) {
                        List<Float> moneyMap = new LinkedList<>();
                        integerListMap.put(i, moneyMap);
                    }

                    for (String key : map.get(0).keySet()) {
                        timeMap.add(key);
                        for (Integer keyM : integerListMap.keySet()) {
                            integerListMap.get(keyM).add(map.get(keyM).get(key));
                        }
                    }

                    if (operationData.size() == 0) {
                        List<OperationData> operationDataLists = new LinkedList<>();
                        for (int i = 0; i <= 10; i++) {
                            OperationData<Float> operationData1 = new OperationData<>();
                            operationData1.setName(operationData.get(i).getName());
                            operationData1.setData(integerListMap.get(i));
                            operationData1.setTime(timeMap);
                            operationDataLists.add(operationData1);
                        }
                    } else {
                        for (int i = 0; i <= 10; i++) {
                            operationData.get(i).setTime(timeMap);
                            operationData.get(i).setData(integerListMap.get(i));
                        }
                    }
                }
            }
        }
        return JsonResult.succ(operationDataList);
    }
}
